﻿using DotSpatial.Controls;
using DotSpatial.Data;
using DotSpatial.Topology;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KASEM
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void cmdAddShp_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDlg = new OpenFileDialog();
            openFileDlg.Filter = "*.shp|*.shp";
            openFileDlg.ShowDialog();
            if (openFileDlg.FileName.Length > 0) 
            {
                kMap.AddLayer(openFileDlg.FileName);
                cmdAddShp.Enabled = false;
                cmdOpenFratureDialog.Enabled = true; 
            }
        }

        private void cmdZoomIn_Click(object sender, EventArgs e)
        {
            kMap.FunctionMode = FunctionMode.ZoomIn;
        }

        private void cmdZoomOut_Click(object sender, EventArgs e)
        {
            kMap.FunctionMode = FunctionMode.ZoomOut;
        }

        private void cmdZoomExtend_Click(object sender, EventArgs e)
        {
            Envelope env = new Envelope();   
            kMap.ViewExtents = kMap.Extent;
        }

        private void cmdPan_Click(object sender, EventArgs e)
        {
            kMap.FunctionMode = FunctionMode.Pan;
        }

        private void cmdInformation_Click(object sender, EventArgs e)
        {
            kMap.FunctionMode = FunctionMode.Info;
        }

        private void cmdOpenFratureDialog_Click(object sender, EventArgs e)
        {
            Form2 frm2 = new Form2();
            frm2.MainMap = kMap;
            frm2.ShowDialog();  
        }

        private void cmdSelection_Click(object sender, EventArgs e)
        {
            kMap.FunctionMode = FunctionMode.Select;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 frm2 = new Form2();
            frm2.CmbTest = comboBox1;
            frm2.ShowDialog(); 
        }
    }
}
